package test.library.behavior;

import test.library.Book;
import test.library.BookList;

import java.util.Scanner;

public class DeleteBook implements IBehavior{
    public void work(BookList bookList){
        System.out.println("删除书籍");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入书籍编号:");
        int num = scanner.nextInt();
        if (num != bookList.getQuantity() - 1){
            Book book = bookList.getBook(bookList.getQuantity() - 1);
            bookList.setBook(num,book);
        }
        bookList.setQuantity(bookList.getQuantity() - 1);
        System.out.println("已删除");
    }
}
